FTP_USER_NAME=oa_open
FTP_USER_PASS=OaOpen@ppp
SUCCESS_FLAG=0--
LOGDIR=/var/log/stat/LOG_SDK/`date +%Y%m -d "-1 days"`
LOGFILENAME=LOG_SDK_`date +%Y%m%d -d "-1 days"`.log 
UPLOADIP=61.172.254.253\ 21
DATE=`date +%Y-%m-%d -d "-1 days"`
REC_FILE_NAME=YZ_REC_OA_OPEN_SDK-"$DATE".TXT
FTP_FILE_NAME=A_OA_OPEN_SDK-"$DATE".TXT

ftp_upload_file()
{
/usr/bin/ftp -i -n $UPLOADIP << _EOF_
user ${FTP_USER_NAME} ${FTP_USER_PASS}
bin
prompt
lcd ${LOGDIR}
cd /sdk
mkdir ${DATE}
cd ${DATE}
put ${LOGFILENAME}
rename ${LOGFILENAME} ${SUCCESS_FLAG}${FTP_FILE_NAME}
lcd /tmp
put ${REC_FILE_NAME}
close
_EOF_
rm -f /tmp/$REC_FILE_NAME
}
create_rec_file()
{
LOG_FILE_COUNT=`cat $LOGDIR/$LOGFILENAME |wc -l`
echo -e "${FTP_FILE_NAME}\t${LOG_FILE_COUNT}"  > /tmp/$REC_FILE_NAME
}
if [ -f "$LOGDIR/$LOGFILENAME" ]; then
create_rec_file
ftp_upload_file
echo 
else
echo "log file($LOGDIR/$LOGFILENAME) not exists."
fi
